//
//  anonymous_objects.hpp
//  learnC++
//
//  Created by apple on 2018/6/4.
//  Copyright © 2018年 yunfan.com. All rights reserved.
//

#ifndef anonymous_objects_hpp
#define anonymous_objects_hpp

#include <stdio.h>
#include <iostream>

//匿名对象
class Cents
{
private:
    int m_cents;
    
public:
    Cents(int cents) { m_cents = cents; }
    
    int getCents() const { return m_cents; }
};

/*
 
 void print(const Cents &cents)
 {
 std::cout << cents.getCents() << " cents";
 }
 
 //调用
 int main()
 {
 Cents cents(6);
 print(cents);
 
 return 0;
 }
 
 
 //匿名调用
 int main(){
 
 print(Cents(6)); // Note: Now we're passing an anonymous Cents value
 return 0;
 }
 */




//For Example
/*
 
 void printValue(int value)
 {
 std::cout << value;
 }
 
 int main()
 {
 int sum = 5 + 3;
 printValue(sum);
 return 0;
 }
 
 //匿名
 int main()
 {
 printValue(5 + 3);
 return 0;
 }
 
 //对象也可以这样
 */


#endif /* anonymous_objects_hpp */
